import Vue from 'vue'
import moment from 'moment'

export default {
  /* ************ 会员列表 *************/
  // 获取列表
  async memberList (data) {
    return Vue.http.post('./gxMemberInfo/getRcMemberList', data)
  },

  /* ************ 会员详情 *************/
  async memberDetail (data) {
    return Vue.http.post('./gxMemberInfo/detailRcMember', data)
  },

  // 修改会员类别
  async updateMemberType (data) {
    return Vue.http.post('./gxMemberInfo/editMemberType', data)
  },

  // 会员参加的活动
  async memberSignUpActivityList (data) {
    return Vue.http.post('./gxActivityBaseInfo/findgxActivitySingUpPage', data)
  },

  /* ************ 会员类别 *************/
  async typeList (data) {
    return Vue.http.post('./gxMemberType/getMemberTypeRcList', data)
  },

  async createType (data) {
    return Vue.http.post('./gxMemberType/saveMemberType', data)
  },

  async updateType (data) {
    return Vue.http.post('./gxMemberType/editMemberType', data)
  },

  async enableType (data) {
    return Vue.http.post('./gxMemberType/isEnableMemberType', data)
  },

  /* ************ 商品及积分兑换 *************/
  // 获取商品列表
  async goodsList (data) {
    return Vue.http.post('./gxRclubSrvpro/getRclubSrvproRcList', data)
  },

  // 新增兑换商品
  async createGoods (data) {
    return Vue.http.post('./gxRclubSrvpro/saveRclubSrvpro', data)
  },

  // 修改兑换商品
  async updateGoods (data) {
    return Vue.http.post('./gxRclubSrvpro/saveRclubSrvpro', data)
  },

  // 获取兑换记录
  async scoreUsedList (data) {
    return Vue.http.post('./gxMemberScoreUsed/getScoreUsedMemberList', data)
  },

  async updateComfigScoreUsed (data) {
    let params = Object.assign({}, data)
    params.confirmDt = moment(params.confirmDt).format('YYYY-MM-DD HH:mm:ss')
    return Vue.http.post('./gxMemberScoreUsed/scoreUsedIsConfirm', params)
  },

  async createComfigScoreUsed (data) {
    let params = Object.assign({}, data)
    params.confirmDt = moment(params.confirmDt).format('YYYY-MM-DD HH:mm:ss')
    return Vue.http.post('./gxMemberScoreUsed/scoreUsedIsConfirm', params)
  },

  /* 协议 */
  async getProtocol (data) {
    return Vue.http.post('./gxMemberProtocol/detailMemberProtocol', data)
  },

  async updateProtocol (data) {
    return Vue.http.post('./gxMemberProtocol/updateMemberProtocol', data)
  },

  /* 会员荣誉 */
  async getHonorList (data) {
    return Vue.http.post('./gxRclubHonor/getRclubHonorList', data)
  },

  async getRclubHonorMemberList (data) {
    return Vue.http.post('./gxRclubHonor/getRclubHonorMemberList', data)
  },

  async createHonorMember (data, selectedMembers) {
    data.pkMemberInfo = ''
    for (let i = 0; i < selectedMembers.length; i++) {
      data.pkMemberInfo = data.pkMemberInfo + selectedMembers[i].pkMemberInfo + ','
    }
    data.pkMemberInfo = data.pkMemberInfo.substring(0, data.pkMemberInfo.length - 1)
    let params = Object.assign({}, data)
    params.honorDate = moment(params.honorDate).format('YYYY-MM-DD HH:mm:ss')
    return Vue.http.post('./gxRclubHonor/saveRclubHonorMember', params)
  },

  async updateHonorMember (data, selectedMembers) {
    data.pkMemberInfo = ''
    for (let i = 0; i < selectedMembers.length; i++) {
      data.pkMemberInfo = data.pkMemberInfo + selectedMembers[i].pkMemberInfo + ','
    }
    data.pkMemberInfo = data.pkMemberInfo.substring(0, data.pkMemberInfo.length - 1)
    let params = Object.assign({}, data)
    params.honorDate = moment(params.honorDate).format('YYYY-MM-DD HH:mm:ss')
    return Vue.http.post('./gxRclubHonor/saveRclubHonorMember', params)
  },

  async removeHonorMember (data) {
    return Vue.http.post('./gxRclubHonor/deleteRclubHonorMember', data)
  }

}
